1
'***************************** Module Header ******************************\
2 '* Module Name: CodeBehindCreation.xaml.vb
3 '* Project: VBSL3Animation
4 '* Copyright (c) Microsoft Corporation.
6 '* This module shows how to initialize a Storyboard in code behind. The final effect
7 '* is the same as BasicPointAnimation.xaml, which uses XAML to add Storyboard.
9 '* This source is subject to the Microsoft Public License.
10 '* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 '* All other rights reserved.
14 '* * 9/10/2009 03:00 PM Allen Chen Created
15 '\**************************************************************************
17 Partial
Public Class CodeBehindCreation
20 Private _myAnimation
As PointAnimation
= New PointAnimation()
21 Private _myAnimationStoryboard
As Storyboard
= New Storyboard()
24 ''' In the following constructor, the PointAnimation is added to Storyboard.
25 ''' They are initialized for animation.
29 _myAnimation
.Duration
= New Duration(TimeSpan
.FromSeconds(2))
30 _myAnimation
.SetValue(Storyboard
.TargetPropertyProperty
, New PropertyPath("Center"))
31 Storyboard
.SetTarget(_myAnimation
, MyAnimatedEllipseGeometry
)
32 _myAnimationStoryboard
.Children
.Add(_myAnimation
)
36 ''' Tbe following event handler change the To property of PointAnimation object,
37 ''' then begin the Storyboard to play the animation. Please note we can change
38 ''' To property even when the animation is playing.
40 ''' <param name="sender"></param>
41 ''' <param name="e"></param>
42 Private Sub MyStackPanel_MouseLeftButtonDown(ByVal sender
As Object, ByVal e
As MouseButtonEventArgs
)
44 Dim targetpoint
= e
.GetPosition(Me.MyStackPanel
)
45 Me._myAnimation
.To = targetpoint
46 Me._myAnimationStoryboard
.Begin()